package com.tgpms.web.element.controller;

import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tgpms.auth.security.TokenService;
import com.tgpms.common.Result;
import com.tgpms.web.element.entity.MaterialExamination;
import com.tgpms.web.element.entity.MaterialExaminationNo;
import com.tgpms.web.element.service.CommodityAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 物资验收app相关接口
 * @author newway
 *
 */
@Api(value = "CommodityAppController", tags = "物资验收app相关接口")
@RestController
@RequestMapping("/ev/CommodityApp")
@Slf4j
public class CommodityAppController {
	
	@Autowired
	private CommodityAppService commodityAppService;
	@Autowired
    private TokenService tokenService;
  
	//移动端物资交验单提交功能
	@ApiOperation(value = "物资交验单提交接口", notes = "物资交验单提交接口", httpMethod = "POST")
    @PostMapping(value = "/checkListFunction")
	public Result<Object> checkListFunction(@RequestBody MaterialExamination en,HttpServletRequest request) {
		log.info("移动端物资交验单提交功能接收的的实体参数为： {}",en.toString());
		en.setModifyUser(tokenService.getUserName(request));
		en.setModifyDate(new Date());
		Result<Object> result = commodityAppService.checkListFunction(en);
		return result;
	}
	
	@ApiOperation(value = "交验单批次增加接口", notes = "交验单批次增加接口", httpMethod = "POST")
	@PostMapping(value = "/addMaterialExaminationNo")
	public Result<Object> addMaterialExaminationNo(@RequestBody MaterialExaminationNo en,HttpServletRequest request) {
		log.info("交验单批次增加接口接收的的实体参数为： {}",en.toString());
		en.setInsertUser(tokenService.getUserName(request));
		en.setInsertDate(new Date());
		Result<Object> result = commodityAppService.addMaterialExaminationNo(en);
		return result;
	}
	
	
	@ApiOperation(value = "交验单批次修改接口", notes = "交验单批次修改接口", httpMethod = "PUT")
    @PutMapping(value = "/updateMaterialExaminationNo")
	public Result<Object> updateMaterialExaminationNo(@RequestBody MaterialExaminationNo en,HttpServletRequest request) {
		log.info("交验单批次修改接口接收的的实体参数为： {}",en.toString());
		en.setModifyUser(tokenService.getUserName(request));
		en.setModifyDate(new Date());
		Result<Object> result = commodityAppService.upMaterialExaminationNo(en);
		return result;
	}
	
	@ApiOperation(value = "交验单批次删除接口", notes = "交验单批次删除接口", httpMethod = "DELETE")
    @DeleteMapping(value = "/delMaterialExaminationNo")
	public Result<Object> delMaterialExaminationNo(@RequestBody MaterialExaminationNo en,HttpServletRequest request) {
		log.info("交验单批次删除接口接收的的实体参数为： {}",en.toString());
		Result<Object> result = commodityAppService.delMaterialExaminationNo(en);
		return result;
	}
    
}
